package com.magicstone.common.pagination.service;


import java.sql.Connection;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;

import com.magicstone.common.pagination.service.Paginator;

@Intercepts({@Signature(type=StatementHandler.class, method="prepare", args = {Connection.class})})
public class PaginationService implements Interceptor{

	private final static Log logger = LogFactory.getLog(PaginationService.class);
	
	public Object intercept(Invocation invocation) throws Throwable {
		return Paginator.process(invocation);
	}

	public Object plugin(Object target) {
		return Plugin.wrap(target, this);
	}

	public void setProperties(Properties properties) {
	}

}
